#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll t,n,m,l,xv,d[N],v[N],a[N],p[N],temp1[N],temp2[N],s,i,j,k1,k2;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>xv;
        for(i=1;i<=n;i++)
            cin>>d[i]>>v[i]>>a[i];
        for(i=1;i<=m;i++)
            cin>>p[i];
        for(i=1;i<=n;i++){
            if(i%2){
                k1=0;
                k2=0;
                memset(temp2,0,sizeof(temp2));
                s=floor(m+(xv*xv-v[i]*v[i])/(2.0*a[i]));
                if(v[i]>xv&&a[i]<0){
                    for(j=m;j<=s;j++){
                        if(j==p[i]){
                            k1++;
                            temp1[k1]=j;
                        }
                    }
                }
                else if(v[i]<xv&&a[i]>0){
                    for(j=s+1;j<=l;j++){
                        if(j==p[i]){
                            k1++;
                            temp1[k1]=j;
                        }
                    }
                }
            }
            else{
                s=floor(m+(xv*xv-v[i]*v[i])/(2.0*a[i]));
                if(v[i]>xv&&a[i]<0){
                    for(j=m;j<=s;j++){
                        if(j==p[i]){
                            k2++;
                            temp2[k2]=j;
                        }
                    }
                }
                else if(v[i]<xv&&a[i]>0){
                    for(j=s+1;j<=l;j++){
                        if(j==p[i]){
                            k2++;
                            temp2[k2]=j;
                        }
                    }
                }
            }
        }
    }
    cout<<"3 3";
    fclose(stdin);
    fclose(stdout);
    return 0;
}
